<template>
  <div class="workModeSetting">
    <div class="operation">
      <el-checkbox
          v-model="checkAll"
          :indeterminate="isIndeterminate"
          @change="handleCheckAllChange"
      >全选
      </el-checkbox>
      <span class="invertSelection" @click="handleInverseSelection">反选</span>
    </div>
    <el-checkbox-group v-model="checkedModes">
      <el-checkbox v-for="(item,index) in cameraModes" :key="index" :label="item.label">{{ item.label }}</el-checkbox>
    </el-checkbox-group>
  </div>
</template>

<script>

export default {
  name: "workModeSetting",
  data() {
    return {
      checkAll: false,
      checkedModes: [],
      isIndeterminate: false,
      cameraModes: [
        {label: '模式1'},
        {label: '模式2'},
        {label: '模式3'},
        {label: '模式4'},
        {label: '模式5'},
        {label: '模式6'},
        {label: '模式7'},
      ]
    };
  },
  components: {},
  mounted() {

  },
  watch: {
    checkedModes(value) {
      if (value.length === 0) {
        this.checkAll = false;
        this.isIndeterminate = false;
      } else if (value.length === this.cameraModes.length) {
        this.checkAll = true;
        this.isIndeterminate = false;
      } else {
        this.checkAll = false;
        this.isIndeterminate = true;
      }
    }
  },
  methods: {
    handleCheckAllChange(val) {
      this.checkedModes = val ? this.cameraModes.map(item => item.label) : [];
      this.isIndeterminate = false;
    },
    handleInverseSelection() {
      this.checkedModes = this.cameraModes
          .map(item => item.label)
          .filter(label => !this.checkedModes.includes(label));
    }
  },
};
</script>

<style lang="scss">
.workModeSetting {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-wrap: nowrap;
  flex-direction: column;
  align-content: flex-start;

  .el-checkbox__label {
    color: #fff;
  }

  .el-checkbox.is-checked {
    color: #24cdff;

    .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
      background-color: #24cdff;
      border-color: #24cdff;
    }
  }

  .el-checkbox__label {
    color: #24cdff;
  }

  .el-checkbox {
    color: rgba(35, 204, 254, 1.00);
  }

  .el-checkbox__input.is-checked + .el-checkbox__label {
    color: rgba(37, 205, 255, 1.00) !important;
  }

  .operation {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;

    .invertSelection {
      margin-left: 30px;
      font-size: 14PX;
      color: rgba(37, 205, 255, 1.00);
      cursor: pointer;
    }

    .el-checkbox__input.is-indeterminate .el-checkbox__inner {
      background-color: rgba(37, 205, 255, 1.00) !important;
      border-color: rgba(37, 205, 255, 1.00) !important;
    }
  }

  .el-checkbox__inner {
    background: rgba(0, 40, 83, 1.00) !important;
  }
}

</style>
